package gdma.hqdes.bean;

import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.io.Serializable;
import java.util.Arrays;

/**
 * @Author wangyue
 * @Version 3.0
 * @Date 2024-07-13
 */

@Data
public class HqdIndexExt implements Serializable {

    @ApiModelProperty("id")
    @TableId
    Long id;

    @ApiModelProperty("指标项id")
    Long indexId;

    @ApiModelProperty("适用区域标签：Z=珠三角，Y=粤东西北，为空表示全部地区")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    String areaTag;

    @ApiModelProperty("（三级指标）指标说明")
    String description;

    @ApiModelProperty("（三级指标）计算类（计算公式无法满足时使用）")
    String calcClass;

    @ApiModelProperty("（三级指标）计算公式")
    String formula;

    @ApiModelProperty("（三级指标）阈值，计算得分<阈值，则最终得分为0分")
    Float thresholdScore;

    @ApiModelProperty("（三级指标）目标值，计算得分>=目标值，则最终得分为100分")
    Float targetScore;

    @ApiModelProperty("逆向指标：0=否，1=是")
    Boolean reverseScoring;

    @ApiModelProperty("填报者角色键值")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    String reporterRole;

    @ApiModelProperty("填报者角色键值2，与上字段为或关系")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    String reporterRole2;

    public String[] getReportRoles() {
        return Arrays.asList(new String[] { reporterRole, reporterRole2 }).stream()
                .filter(e -> e != null).toArray(String[]::new);
    }

    @ApiModelProperty("审核者角色键值")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    String auditorRole;

    @ApiModelProperty("审核者角色键值2，与上字段为优先关系，本字段为空时为一级审核；非空时则为“初审-复审”二级审核，此时本字段为复审权限角色")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    String auditorRole2;

    @ApiModelProperty("审核者角色键值3，与上字段为优先关系，本字段为空时为一/二级审核；非空时则为“初审-复审-终审”三级审核，此时本字段为终审权限角色")
    @TableField(updateStrategy = FieldStrategy.IGNORED)
    String auditorRole3;

    public String[] getAuditorRoles() {
        return Arrays.asList(new String[] { auditorRole, auditorRole2, auditorRole3 }).stream()
                .filter(e -> e != null).toArray(String[]::new);
    }

}
